<template>
	<view class="page">
		<view class="flex align-center justify-between bg-white text-lg text-bold custom "
			:style="[{height: CustomBar+'px',paddingTop: StatusBar+'px'}]">
			<text class="cuIcon-back padding-left" @click="back"></text>
			<text style="color: #333;">商家资质认证</text>
			<text></text>
		</view>
		<view class="result-info margin-lr margin-top text-center  padding-tb-xl text-df"
			v-if="info.joinin_state == 1 ||info.joinin_state == 4">
			<image src="../../static/rz-bg.png" mode=""></image>
			<view class="result-info-title text-lg">
				<view class="flex-direction  align-start" style="font-size: 36rpx;text-align: center;"
					v-if="info.joinin_state == 1">
					<view class="margin-top-sm text-333 text-bold"> 资料审核中...</view>
					<text class="margin-top-sm text-333 text-bold"> 请确保手机畅通，注意接听平台电话审核</text>
				</view>

				<view class="flex-direction  align-start" style="font-size: 36rpx;text-align: center;" v-if="info.joinin_state == 4">
					<!-- <text class="margin-top-sm text-333 text-bold" style="font-size: 36rpx;"> 待财务审核</text> -->
					<text class="margin-top-sm text-333 text-bold"> 待财务审核</text>
				</view>

			</view>
			<!-- 首页 -->
			<view class="btn active" @click="goLogin">返回</view>
		</view>
		<view 
			v-if="info.joinin_state == 2 ||info.joinin_state == 5 ">
			<view class="result-infos margin-lr margin-top  bg-white  text-df" style="border-radius:20rpx ;">
				<view class="text-333 padding">平台认证保证金:{{money}}元</view>
				<view  class="text-333 text-bold margin padding " style="text-align: center;font-size: 55rpx;padding-bottom: 100rpx;"> ￥{{money}}</view>
			</view>
			<view class="margin-lr">
				选择支付方式
			</view>
			<view class="result-infos margin-lr margin-top  bg-white  text-df" style="border-radius:20rpx ;">
				<view class="text-333 padding">线下打款</view>
			</view>
			<!-- <image src="../../static/rz-bg.png" mode=""></image> -->
		<!-- 	<view class="result-info-title text-lg" style="margin-left: 71rpx;">
				<text class="text-333">平台认证保证金</text>
				<text v-if="info.joinin_state == 2" class="text-333 text-bold"> 审核通过</text>

				<view class="flex flex-direction">
					<text v-if="info.joinin_state == 5" class="text-333 text-bold"> 审核通过</text>
					<image src="../../static/line.png" mode="" v-if="info.joinin_state == 5"
						style="width: 128rpx;height: 8rpx;"></image>
				</view>


			</view> -->
			<!-- <view class="text-666 margin-top-xs" v-if="info.joinin_state == 1 || info.joinin_state == 4 ">信息审核中，请稍等~</view>
      <view class="text-666 margin-top-xs" v-if="info.joinin_state == 3 || info.joinin_state == 6 ">信息审核失败，请重试~</view> -->
			<view class="btn-wrap   margin-top" v-if="info.joinin_state == 2 || info.joinin_state == 6">
				<view class="btn" @click="handlerPay"> 去支付</view>
				<view class="agreement">
					<image class="image" @click="handle_select" v-if="is_select_agree" src="../../../user/static/checked.png">
					</image>
					<image class="image" @click="handle_select" v-else src="../../../user/static/unchecked.png"></image>
					<view>我已阅读并同意 <text style="color: #4E8CEE;">《商家规范》</text></view>
				</view>
			</view>

			<view class="btn-wrap flex  margin-top" v-if="info.joinin_state == 5">
				<view class="btn" @click="goLogin"> 去登录</view>
			</view>
		</view>
		<view class="result-infoss margin-lr margin-top  bg-white padding-tb-xl text-df"
			v-if="info.joinin_state == 3 ||info.joinin_state == 6">
			<!-- <image src="../../static/rz-bg.png" mode=""></image> -->
			<view class="result-info-title text-lg" style="margin-left: 71rpx;">

				<text v-if="info.joinin_state == 3" class="text-333 text-bold"> 审核失败</text>


				<text v-if="info.joinin_state == 6" class="text-333 text-bold"> 审核失败</text>
			</view>
			<!-- <view class="text-666 margin-top-xs" v-if="info.joinin_state == 1 || info.joinin_state == 4 ">信息审核中，请稍等~</view>
      <view class="text-666 margin-top-xs" v-if="info.joinin_state == 3 || info.joinin_state == 6 ">信息审核失败，请重试~</view> -->
			<view class="btn-wrap flex justify-center margin-top"
				v-if="info.joinin_state == 2 || info.joinin_state == 6">
				<view class="btn" @click="handlerPay"> 去支付</view>
			</view>
			<view class="btn-wrap flex  margin-top" v-if="info.joinin_state == 3">
				<view class="btn" @click="handlerAddInfo">重新提交</view>
			</view>

		</view>
		<view class="margin-lr " v-if="info.joinin_state == 3 || info.joinin_state == 6 ">
			<view class="padding-lr padding-tb-sm margin-top-sm text-df text-666">
				审核信息
			</view>
			<view class="bg-white radius-16  padding text-df">
				<view class="_left" style='margin-bottom: 10rpx'>
					拒绝理由
				</view>
				<view class="_right text-cut  text-cut  ">
					{{info.reason? info.reason:'无'}}
				</view>
			</view>
		</view>
		<!-- <view class="padding-lr padding-tb-sm margin-top-sm text-df text-666">
      会员信息
    </view>
    <view class="shop-item bg-white height-100 padding-lr text-df flex justify-between align-center solid-bottom">
      <view class="_left">
        会员昵称
      </view>
      <view class="_right text-cut  text-cut  text-right">
        13246533724
      </view>
    </view> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				is_select_agree: false,
				money:0,
				info: {
					pay: [],
					company: [],
					person: [],
					licence: '',
					settlement: [],
					store: [],
					reason: '',
					account: ''
				}
			}
		},
		onShow() {
			this.getData();
			this.getPayInfo();
		},
		onLoad(option) {

			// let pages = getCurrentPages();
			// let prevPage = pages[pages.length - 2]; //上一个页面
			// console.log(JSON.stringify(pages),JSON.stringify(prevPage))
		},
		onPullDownRefresh() {
			this.getData();
			uni.stopPullDownRefresh();
		},
		methods: {
			getPayInfo() {
				let store_joinin_id = uni.getStorageSync('store_joinin_id') || 0;
				let store_user_id = uni.getStorageSync('store_user_id') || 0;
				this.$api.post(global.apiUrls.payInfo, {}, {
					header: {
						Storeid: store_joinin_id,
						Userid: store_user_id
					}
				}).then(res => {
					console.log(res);
					if (res.data.code == 1) {
						this.account = res.data.data.account;
						this.money = this.account.money
					}
				}).catch(err => {
					console.log(err);
				})
			},
			handlerLogin() {
				this.$message.info('请通过链接下载商家端app');
			},
			preview(url) {
				uni.previewImage({
					current: url,
					urls: [url]
				})
			},
			// 去支付
			handlerPay() {
				if (!this.is_select_agree) return this.$message.info('请阅读并同意以上协议');
				uni.navigateTo({
					url: '/shop/shop/shop-pay/index'
				})
				// let postdata = {
				// 	order_type: 13,
				// 	order_money: this.account.money
				// }

				// this.$api.post(global.apiUrls.postCreateOrder, postdata).then(res => {
				//   if (res.data.code == 1) {
				//     this.$message.info(this.i18n['订单提交成功，请支付…']);
				//     this.$api
				//       .get(global.apiUrls.getOrderDetail, {
				//         order_sn: res.data.data.order_sn,
				//         order_type: 13
				//       })
				//       .then(response => {
				//         setTimeout(() => {
				//           this.$urouter.redirectTo({
				//             url: '/pages/goods/shop/pay-order/index',
				//             params: {
				//               order_sn: res.data.data.order_sn,
				//               order_type: 13
				//             }
				//           });
				//         }, 500);
				//       });
				//   } else {
				//     this.$message.info(res.data.msg);
				//   }
				// });
			},
			// 重填信息
			handlerAddInfo() {
				uni.navigateTo({
					url: '/shop/shop/shop-agreement/index'
				})
			},
			goLogin() {
				uni.reLaunch({
					url: '/pages/user/login/login-password/index'
				});
			},
			handle_select() {
				this.is_select_agree = !this.is_select_agree
			},
			back() {
				// uni.navigateBack()
				uni.reLaunch({
					url: '/pages/user/login/login-password/index'
				});
			},
			getData() {
				let store_joinin_id = uni.getStorageSync('store_joinin_id') || 0;
				let store_user_id = uni.getStorageSync('store_user_id') || 0;
				this.$api.post(global.apiUrls.apply, {}, {
					header: {
						Storeid: store_joinin_id,
						Userid: store_user_id
					}
				}).then(res => {
					console.log(res, '暂停');
					if (res.data.code == 1) {
						let state = 1
						this.info = res.data.data;
						if(this.info.joinin_state  == 5) {
							state = 2
							uni.switchTab({
								url: '/pages/tab/home/home/index'
							})
						}
						setTimeout(()=> {
							if(state == 1) {
								this.getData()
							}
						}, 8000)
					} else {
						this.$message.info(res.data.msg);
					}
				}).catch(err => {
					console.log(err);
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	

	.page {
		padding-bottom: 120rpx;
	}

	.check-box {
		margin-left: 64rpx;

		image {
			width: 182rpx;
			height: 8rpx;
		}
	}

	// .result-info {
	// 	border-radius: 16rpx;
	// 	// height: 210rpx;
	// 	background: url('../../static/rz-bg.png') no-repeat left top;
	// 	background-size: 100% 100%;
	// }

	// .result-infos {
	// 	border-radius: 16rpx;
	// 	height: 210rpx;
	// 	background: url('../../static/rz-bg2.png') no-repeat left top;
	// 	background-size: 100% 100%;
	// }

	// .result-infoss {
	// 	border-radius: 16rpx;
	// 	height: 210rpx;
	// 	background: url('../../static/rz-bg-1.png') no-repeat left top;
	// 	background-size: 100% 100%;
	// }

	.result-info-title {
		color: #FF9B26;
	}

	.height-100 {
		min-height: 100rpx;
		height: initial;
	}

	.text-bf {
		color: #bfbfbf;
	}

	.shop-item {
		._left {
			width: 300rpx;
		}

		._right {
			width: calc(100% - 300rpx);
			display: flex;
			align-items: center;
			justify-content: flex-end;
			text-align: right;

			&.image {
				padding: 20rpx 0;
			}

			.up-img {
				width: 320rpx;
				height: 150rpx;
				border: 1px dashed #EEEEEE;
				position: relative;

				&::before {
					content: '';
					width: 60rpx;
					height: 4rpx;
					background: #EEEEEE;
					position: absolute;
					top: 50%;
					left: 50%;
					transform: translate(-50%, -50%);
				}

				&::after {
					content: '';
					width: 4rpx;
					height: 60rpx;
					background: #EEEEEE;
					position: absolute;
					top: 50%;
					left: 50%;
					transform: translate(-50%, -50%);
				}
			}

			.img {
				height: 150rpx;
			}

		}
	}

	.btn-wrap {
		// .btn {
		// 	width: 160rpx;
		// 	height: 64rpx;
		// 	line-height: 64rpx;
		// 	text-align: center;
		// 	font-size: 28rpx;
		// 	color: #FA9B46;
		// 	// background: $bgtheme;
		// 	border: 1rpx solid #FA9B46;
		// 	border-radius: 32rpx;
		// 	margin-left: 52rpx;
		// }

	}

	.finish {
		color: #FA9B46;
		margin-left: 71rpx;
	}

	.custom {
		position: sticky;
		top: 0;
		width: 100%;
		left: 0;
		z-index: 9999;

	}

	.radius-16 {
		border-radius: 16rpx !important;
		overflow: hidden;
	}
	.btn {
		width: 95%;
		height: 88rpx;
		line-height: 88rpx;
		background: $bgtheme;
		opacity: 1;
		border-radius: 14rpx;
		margin: 80rpx auto;
		font-size: 32rpx;
		color: #FFFFFF;
		font-family: PingFang SC;
		font-weight: 500;
		text-align: center;
	}
	.agreement {
		display: flex;
		width: 100%;
		font-family: PingFangSC-Regular;
		font-size: 28rpx;
		color: #666666;
		align-items: center;
		justify-content: center;
		margin: 30rpx 0;
	
		.image {
			height: 28rpx;
			width: 28rpx;
			margin-right: 12rpx;
		}
	
		text {
			color: #999999;
		}
	}
</style>